import React, { Component } from 'react'

export default class Test extends Component {
  constructor() {
    super()
    console.log('挂载-constructor')
  }
  state = {
    xxx: '123',
  }
  render() {
    console.log('挂载/更新-render')
    return (
      <div>
        Test,
        <button
          onClick={() => {
            // this.setState({
            //   xxx: this.state.xxx + 'x',
            // })

            this.forceUpdate()
          }}
        >
          test自己的按钮,修改自己的状态
        </button>
      </div>
    )
  }
  componentDidMount() {
    console.log('挂载-componentDidMount-组件第一次渲染到页面上完成')
  }

  componentDidUpdate() {
    console.log('更新-componentDidUpdate-组件重新渲染完毕了')
  }

  componentWillUnmount() {
    console.log('卸载-componentWillUnmount-组件即将销毁')
  }
}
